package me.hushuang.webb.back.mapper;


import me.hushuang.webb.back.model.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 *
 */
public interface RoleMapper {

    @Insert("insert into sys_role(role, description, resource_ids, available) values(#{role}, #{description}, #{resourceIdsStr}, #{available})")
    int createRole(final Role role);

    @Update("update sys_role set role = #{role}, description=#{description}, resource_ids=#{resourceIdsStr}, available=#{available} where id=#{id}")
    Role updateRole(Role role);

    @Delete("delete from sys_role where id= #{id}")
    void deleteRole(Long roleId);

    @Select("select id, role, description, resource_ids as resourceIdsStr, available from sys_role where id=#{id}")
    Role findOne(Long roleId);

    @Select("select id, role, description, resource_ids as resourceIdsStr, available from sys_role")
    List<Role> findAll();

}
